import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class StreamWidget extends StatefulWidget {
  const StreamWidget({Key? key}) : super(key: key);

  @override
  State<StreamWidget> createState() => _StreamWidgetState();
}

class _StreamWidgetState extends State<StreamWidget> {
  @override
  void initState() {
    super.initState();
  }

  void onDone() {
    debugPrint('-----Done-----!');
  }

  void onError(error) {
    debugPrint('Error: $error');
  }

  void onData(String data) {
    //data参数表示的就是_streamDemo这个Stream出来的数据
    debugPrint('$data');
  }

  void onData1(String data) {
    //data参数表示的就是_streamDemo这个Stream出来的数据
    debugPrint('$data');
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        GestureDetector(
          onTap: () {
            Navigator.pop(context);
          },
          child: const Padding(
            padding: EdgeInsets.all(20),
            child: Text(
              '返回',
              style: TextStyle(
                  color: Colors.white,
                  fontSize: 20,
                  decoration: TextDecoration.none),
            ),
          ),
        ),
        Expanded(child: _listItem()),
        Container(
          color: Colors.white,
          width: double.infinity,
          padding: EdgeInsets.all(30),
          child: Center(
            child: Text('传递值',style: TextStyle(color: Colors.black54,fontSize: 19,decoration: TextDecoration.none),),
          ),
        )
      ],
    );
  }

  Widget _listItem() {
    var names = ['Stream','StreamControl','StreamSkin','StreamSubscription'];
    return ListView.builder(itemBuilder: (context, item) {
      return GestureDetector(
        onTap: (){

        },
        child: Container(
            padding: EdgeInsets.all(20),
            child:Text(names[item],style: TextStyle(color: Colors.white,fontSize: 19,decoration: TextDecoration.none),)
        ),
      );
    },
    shrinkWrap: true,
      itemCount: names.length,
    );
  }

}
